package 树;

public class Demo04 {
    /*
    * 深度优先搜索
    * */
    static class Solution {
        public boolean isSymmetric(TreeNode root) {
            if(root == null){
                return true;
            }
            return isSymmetricChild(root.left,root.right);
        }

        public boolean isSymmetricChild(TreeNode lNode,TreeNode rNode){
            if(lNode == null && rNode == null) return true;
            if(lNode == null || rNode == null) return false;
            if(lNode.val != rNode.val) return false;
            return isSymmetricChild(lNode.right,rNode.left) && isSymmetricChild(lNode.left,rNode.right);
        }

    }
}
